<style scoped>
    .layui-row {
        overflow: hidden;
    }
    .select-item {
        float: left;
        width: 100%;
        height: auto !important;
        word-break:break-all;
    }
    .layui-row:after, .layui-row:before {
        clear: none;
    }
    .layui-form >>> .layui-form-select{
        z-index: inherit;
    }
    .department >>> .layui-table td, .layui-table th {
        padding: 9px 2px;
        white-space: nowrap;
    }
    select{
        color: #eee
    }
    option{
        color: #000;
    }
    .layui-inline {
        padding: 5px 0;
    }
    .layui-colla-content {
        border-top: none;
    }
    .layui-colla-title {
        background: none;
        padding-left: 15px !important;
        height: auto;
    }
    .department >>> .layui-colla-icon {
        left: auto;
        right: 15px !important;
    }
    .layui-collapse {
        border: 0 !important;
    }
    /*.department {*/
    /*    position: relative;*/
    /*}*/
    .openicon {
        position: absolute;
        right: 15px;
        top: 10px;
        z-index: 100000;
        border-radius: 50%;
        color: #fff;
        width: 24px;
        text-align: center;
        height: 24px;
        line-height: 24px;
        background: rgba(0,150,136, 0.7);
    }
    .nodata {
        background: #f2f2f2;
        color: #333;
        text-align: center;
        padding: 5px 0;
    }
</style>

<template>
    <div class="department">
        <form class="layui-form " >

            <div  class="layui-col-lg4 select-item" v-show="searchStatus" >
                <label>查询条件: </label>
                <div class="layui-inline" style="width: 190px">
                    <input type="text" v-model="starttime" id="starttime" autocomplete="off" placeholder="请选择开始时间" class="layui-input key">
                </div>
                <div class="layui-inline" style="width: 190px">
                    <input type="text" v-model="endtime" id="endtime" autocomplete="off"  placeholder="请选择结束时间" class="layui-input key">
                </div>
                <div class="layui-inline" style="width: 190px">
                    <select id="currentDepart" name="depguid" lay-filter="departid" placeholder="请选择部门"   class="layui-form-select" lay-search   >
                        <option value="">请选择部门</option>
                        <option v-for="(item, index) in departments" :key="item.guid" :value="item.guid">{{item.name}}</option>
                    </select>
                </div>
                <div class="layui-inline" style="width: 190px">
                    <select id="currentApply" name="operatorid" class="layui-form-select" lay-search   >
                        <option value="">请选择销售人员</option>
                        <option v-for="(item, index) in applyers" :key="item.guid" :value="item.guid">{{item.realname + "(" + item.telphone + ")"}}</option>
                    </select>
                </div>
                <div class="layui-inline" style="width: 190px;">
                    <select id="currentRoom" name="storermguid" placeholder="请选择库房" class="layui-form-select"  lay-search  >
                        <option value="">请选择库房</option>
                        <option v-for="(item, index) in storeroom" :key="item.guid" :value="item.guid">{{item.name}}</option>
                    </select>
                </div>
                <div class="layui-inline" style="width: 190px; margin-left: 64px;">
                    <select id="currentCustomer" name="customerguid" class="layui-form-select" lay-search >
                        <option value="">请选择客户</option>
                        <option v-for="(item, index) in customers" :key="item.guid" :value="item.guid">{{item.name}}</option>
                    </select>
                </div>
                <div class="layui-inline" style="width: 190px">
                    <select id="currentProduct" name="" class="layui-form-select" lay-search lay-filter="product" >
                        <option value="">请选择产品</option>
                        <option v-for="(item, index) in products" :key="item.guid" :value="item.guid">{{item.productname}}</option>
                    </select>
                </div>

                <div class="layui-inline" style="width: 190px">
                    <select id="currentSp" name="" class="layui-form-select" lay-search >
                        <option value="">请选择规格</option>
                        <option v-for="(item, index) in sps" :key="item.guid" :value="item.guid">{{item.name}}</option>
                    </select>
                </div>
                <div class="layui-inline" style="width: 190px" id="statline"></div>
                <div class="layui-inline" style="width: 190px" id="paytype"></div>
                <div class="layui-inline" style="width: 190px;margin-left: 64px;">
                    <input type="text" v-model="starttime2" id="starttime2" autocomplete="off" placeholder="请选择开始结算时间" class="layui-input key">
                </div>
                <div class="layui-inline" style="width: 190px">
                    <input type="text" v-model="endtime2" id="endtime2" autocomplete="off"  placeholder="请选择截止结算时间" class="layui-input key">
                </div>
                <div class="layui-inline" style="width: 190px;">
                    <input type="text" v-model="starttime3" id="starttime3" autocomplete="off" placeholder="请选择开始出库时间" class="layui-input key">
                </div>
                <div class="layui-inline" style="width: 190px">
                    <input type="text" v-model="endtime3" id="endtime3" autocomplete="off"  placeholder="请选择截止出库时间" class="layui-input key">
                </div>
                <div class="layui-inline" style="width: 190px">
                    <input type="text" id="sellcode" placeholder="输入销售单编号/车牌号" class="layui-input key">
                </div>
            </div>

            <div  class="layui-col-lg4 select-item" style="position: relative;" >
                <div class="openicon">
                    <i v-if="searchStatus" @click="closeSearch" class="layui-icon layui-icon-up"></i>
                    <i v-if="!searchStatus" @click="openSearch" class="layui-icon layui-icon-down"></i>
                </div>
                <label>汇总条件: </label>
                <div class="layui-inline">
                    <input type="checkbox" name="depcondition" id="depcondition" value="depart"  title="销售部门" >
                    <input type="checkbox" name="applycondition" id="applycondition" value="apply"  title="销售人员" >
                    <input type="checkbox" name="srcondition" id="srcondition" value="sr"  title="库房" >
                    <input type="checkbox" name="customercondition" id="customercondition" value="customer"  title="客户" >
                </div>
                <div class="layui-inline" style="width: 225px;height: auto">
                    <select v-model="ordercondition" name="ordercondition" id="ordercondition"  class="layui-form-select"   >
                        <option value="">请选择产品或规格</option>
                        <option value="product">产品</option>
                        <option value="sp">规格</option>
                    </select>
                </div>
                <button type="button" class="layui-btn sou" @click="search">搜索</button>
                <button type="button" class="layui-btn sou" @click="exportExcel">导出excel</button>
            </div>

        </form>
        <div style="width: 100%; overflow: auto;margin-bottom: 10px;" id="textarea">
            <table class="layui-table layui-form" >
                <thead>
                <tr v-if="listdata.length != 0 && listdata[0].sellcode !== ''" >
                    <th>销售单号</th>
                    <th>订单时间</th>
                    <th>订单状态</th>
                    <th>销售部门</th>
                    <th>销售人员</th>
                    <th>客户名称</th>
<!--                    <th>收货地址</th>-->
                    <th>联系电话</th>
                    <th>计价方式</th>
                    <th>支付方式</th>
                    <th>出库库房</th>
<!--                    <th>出库重量</th>-->
                    <th>出库时间</th>
                    <th>到货重量</th>
                    <th>结算金额</th>
                    <th>结算时间</th>
                    <th>退换货</th>

                    <th>品种</th>
                    <th>规格</th>
                    <th>出库重量</th>
                    <th>结算重量</th>
                    <th>订单数量</th>
                    <th>赠送数量</th>
                    <th>结算数量</th>
                    <th>单位</th>
                    <th>单价</th>
                    <th>
                        结算金额
                    </th>
                    <th>
                        回款金额
                    </th>
                    <th>
                        收货地址
                    </th>
                    <th>
                        收货人
                    </th>
                    <th>
                        运输车牌号
                    </th>
                    <th>
                        备注
                    </th>

                </tr>
                <tr v-else>
                    <th v-if="listdata.length != 0 && listdata[0].depname !== '' && listdata[0].depname !== undefined">销售部门</th>
                    <th v-if="listdata.length != 0 && listdata[0].applyname !== '' && listdata[0].applyname !== undefined">销售人员</th>
                    <th v-if="listdata.length != 0 && listdata[0].customername !== '' && listdata[0].customername !== undefined">客户名称</th>
                    <th v-if="listdata.length != 0 && listdata[0].customerphone !== '' && listdata[0].customerphone !== undefined">联系电话</th>
                    <th v-if="listdata.length != 0 && listdata[0].storeroomname !== '' && listdata[0].storeroomname !== undefined">出库库房</th>
                    <th v-if="listdata.length != 0 && listdata[0].productname !== '' && listdata[0].productname !== undefined">品种</th>
                    <th v-if="listdata.length != 0 && listdata[0].spname !== '' && listdata[0].spname !== undefined">规格</th>
                    <th v-if="listdata.length != 0 && listdata[0].siloadweihgt !== '' && listdata[0].siloadweihgt !== undefined">出库重量</th>
                    <th v-if="listdata.length != 0 && listdata[0].siunloadweight !== '' && listdata[0].siunloadweight !== undefined">结算重量</th>
                    <th v-if="listdata.length != 0 && listdata[0].sifinalamount !== '' && listdata[0].sifinalamount !== undefined">结算金额</th>
                </tr>
                </thead>
                <tbody>
                <template v-if="listdata.length != 0 && listdata[0].sellcode !== ''" v-for="(item) in afterList" >
                    <tr class="id9"  v-for="(row, i) in item" >
<!--                    <td>{{row.srname}}</td>-->
<!--                    <td v-if="listdata[0] !== undefined && (othercondition== 'sh' || othercondition== 'product' || othercondition== 'sp') " >{{row.shname}}</td>-->
<!--                    <td v-if="listdata[0] !== undefined && listdata[0].companyname !== '' && listdata[0] !== undefined && listdata[0].companyname !== undefined && showCompany  " >{{row.companyname}}</td>-->
<!--                    <td v-if="listdata[0] !== undefined && (othercondition== 'sp' || othercondition== 'product') " >{{row.productname}}</td>-->
<!--                    <td v-if="listdata[0] !== undefined && othercondition== 'sp' " >{{row.specname}}</td>-->
                    <td @click="openOrder(row.guid)" style="cursor: pointer;" v-if="i === 0" :rowspan="item.length">{{row.sellcode}}</td>
                    <td v-if="i === 0" :rowspan="item.length">{{row.createtime}}</td>
                    <td v-if="i === 0" :rowspan="item.length">{{row.statusname}}</td>
                    <td v-if="i === 0" :rowspan="item.length">{{row.depname}}</td>
                    <td v-if="i === 0" :rowspan="item.length">{{row.applyname}}</td>
                    <td v-if="i === 0" :rowspan="item.length">{{row.customername}}</td>
<!--                    <td v-if="i === 0" :rowspan="item.length">{{row.arriaddres}}</td>-->
                    <td v-if="i === 0" :rowspan="item.length">{{row.customerphone}}</td>
                    <td v-if="i === 0" :rowspan="item.length">{{row.settletypename}}</td>
                    <td v-if="i === 0" :rowspan="item.length">{{row.paytypename}}</td>
                    <td v-if="i === 0" :rowspan="item.length">{{row.storeroomname}}</td>
<!--                    <td v-if="i === 0" :rowspan="item.length">{{row.loadweight}}</td>-->
                    <td>{{row.outtime}}</td>
                    <td v-if="i === 0" :rowspan="item.length">{{row.unnloadweight}}</td>
                    <td v-if="i === 0" :rowspan="item.length">{{row.finalamount}}</td>
                    <td v-if="i === 0" :rowspan="item.length">{{row.settletime}}</td>
                    <td v-if="i === 0" :rowspan="item.length">{{row.withdrawtypename}}</td>
                    <td>{{row.productname}}</td>
                    <td>{{row.spname}}</td>
                    <td>{{row.siloadweihgt}}</td>
                    <td>{{row.siunloadweight}}</td>
                    <td>{{row.orderpack}}</td>
                    <td>{{row.handselcount}}</td>
                    <td>{{row.sisettlecount}}</td>
                    <td>{{row.unit}}</td>
                    <td>{{row.price}}</td>
                    <td>{{row.sifinalamount}}</td>
                        <td>
                            {{row.backmoney}}
                        </td>
                        <td v-if="i === 0" :rowspan="item.length">
                            {{row.arriprovince}}{{row.arricity}}{{row.arridistrict}}{{row.arriaddres}}
                        </td>
                        <td v-if="i === 0" :rowspan="item.length">
                            {{row.arricontact}}[{{row.arricontactno}}]
                        </td>
                        <td v-if="i === 0" :rowspan="item.length">
                            {{row.carcode}}
                        </td>
                        <td v-if="i === 0" :rowspan="item.length">
                            {{row.remarks}}
                        </td>

                </tr>
                </template>
                <template v-else >
                    <tr class="id9"  v-for="(row, i) in listdata" >
                        <td v-if="listdata.length != 0 && listdata[0].depname !== '' && listdata[0].depname !== undefined">{{row.depname}}</td>
                        <td v-if="listdata.length != 0 && listdata[0].applyname !== '' && listdata[0].applyname !== undefined">{{row.applyname}}</td>
                        <td v-if="listdata.length != 0 && listdata[0].customername !== '' && listdata[0].customername !== undefined">{{row.customername}}</td>
                        <td v-if="listdata.length != 0 && listdata[0].customerphone !== '' && listdata[0].customerphone !== undefined">{{row.customerphone}}</td>
                        <td v-if="listdata.length != 0 && listdata[0].storeroomname !== '' && listdata[0].storeroomname !== undefined">{{row.storeroomname}}</td>
                        <td v-if="listdata.length != 0 && listdata[0].productname !== '' && listdata[0].productname !== undefined">{{row.productname}}</td>
                        <td v-if="listdata.length != 0 && listdata[0].spname !== '' && listdata[0].spname !== undefined">{{row.spname}}</td>
                        <td v-if="listdata.length != 0 && listdata[0].siloadweihgt !== '' && listdata[0].siloadweihgt !== undefined">{{row.siloadweihgt}}</td>
                        <td v-if="listdata.length != 0 && listdata[0].siunloadweight !== '' && listdata[0].siunloadweight !== undefined">{{row.siunloadweight}}</td>
                        <td v-if="listdata.length != 0 && listdata[0].sifinalamount !== '' && listdata[0].sifinalamount !== undefined">{{row.sifinalamount}}</td>
                    </tr>
                </template>
                </tbody>
            </table>
            <p class="nodata" v-show="nodata">没有数据！</p>
        </div>
        <Pagination :cur="currentPage" :all="totalPage" :callback="turnPage" @doChageSize="changePageSize" :isSaleReport="true" ></Pagination>
    </div>
</template>

<script>
    import Pagination from '../common/Pagination.vue'

    let qs = require('qs');
    export default {
        name: 'Exporywhinform',
        components: {Pagination},
        data () {
            return {
                departments: [],
                currentDepart: '',
                applyers: [],
                currentApply: '',
                storeroom:[],
                currentRoom: '',
                customers: [],
                currentCustomer: '',
                products: [],
                currentProduct: '',
                sps: [],
                currentSp: '',
                status: [],
                stats: [],
                currentStatus: '',
                statline: '',
                currentPage: 1,
                pageSize: 10,
                rows: 10,
                totalPage: 0,
                afterList: [],
                starttime:"",
                endtime:"",
                starttime2:"",
                endtime2:"",
                starttime3:"",
                endtime3:"",
                srguid:"",
                listdata:[],
                exportpage:1,
                depcondition: '',
                applycondition: '',
                srcondition: '',
                customercondition: '',
                ordercondition: '',
                searchStatus: true,
                nodata: false,
                paytypes: [],
                currentPage: 1,
                totalPage: 0,
            }
        },
        mounted() {
            let that = this;
            //this.getRoomsAndDepart();
            this.getRooms();
            this.getDeparts();
            this.getCustomer();
            this.getApplyer();
            this.getProduct();
            //this.getSps();
            this.getStatus();
            this.getPaytypes();
            this.starttime = this.getNowMonthDate();
            this.endtime = this.getDate();
            layui.use('laydate', function(){
                var laydate = layui.laydate;

                //执行一个laydate实例
                laydate.render({
                    elem: '#starttime', //指定元素
                    // value: that.getNowMonthDate()
                });
                laydate.render({
                    elem: '#endtime',
                });
                laydate.render({
                    elem: '#starttime2',
                });
                laydate.render({
                    elem: '#endtime2',
                });
                laydate.render({
                    elem: '#starttime3',
                });
                laydate.render({
                    elem: '#endtime3',
                });
            });
            layui.use(['form'], function () {
                var form = layui.form;
                form.on('select(departid)', function(data){
                    that.getApplyer(data.value)
                    that.getCustomer();
                    form.render('select');//select是固定写法 不是选择器
                });
                form.on('select(product)', function(data){
                    that.getSps(data.value)
                    form.render('select');//select是固定写法 不是选择器
                });
            });
        },
        updated: function () {
            layui.form.render('select');
            layui.form.render();
        },
        methods: {
            changePageSize: function(val) {
                this.pageSize = val;
                this.getPageData();
            },
            turnPage: function(data){
                this.currentPage = data;
                this.getPageData();
            },
            openOrder: function(id) {
                let url = '';
                if (location.href.indexOf("?") > -1) {
                    url = location.href.substring(0, location.href.indexOf("?"));
                } else {
                    url = location.href;
                }
                window.open(url + '?pid=' + id + '&component=ViewSellform');
                // this.$parent.gid = id;
                // this.$parent.switchPage('ViewSellform');
            },
            openSearch: function() {
                this.searchStatus = true;
            },
            closeSearch: function() {
                this.searchStatus = false;
            },
            //获取当前日期
            getDate: function (dayCount = 0) {
                var dd = new Date();
                dd.setDate(dd.getDate()+dayCount);//设置日期
                var y = dd.getFullYear();
                var m = dd.getMonth()+1;//获取当前月份的日期
                var fullM = m.length == 2 ? m : '0' + m;
                var d = dd.getDate();
                return y+"-"+fullM+"-"+d;
            },
            //获取本月第一天
            getNowMonthDate: function () {
                var date = new Date();
                var year = date.getFullYear() + "";
                var month = (date.getMonth() + 1) + "";
                // 本月第一天日期
                var begin = year + "-" + month + "-01"
                return begin;
            },
            // 数据转换
            tansList () {
                this.afterList = Object.values(this.listdata.reduce((temp, item) => {
                    if( temp[item.sellcode] ) {
                        temp[item.sellcode].push(item)
                    }else {
                        temp[item.sellcode]  = [item]
                    }
                    return temp
                },{}))
            },
            search: function() {
                this.getPageData('search');
            },
            getPageData: function(type = '') {
                if (this.dateToValue($('#endtime').val()) < this.dateToValue($('#starttime').val())) {
                    this.toastText('结束时间须大于起始时间！');
                    return;
                }
                var that = this;
                let loader = layui.layer.load();

                let postData = {};
                postData = this.setPostData(type);
                $.ajax({
                    url: '/sales/Sellform!rptSellForm.action',
                    type: "post",
                    data: postData,
                    dataType: "json",
                    success: function(res) {
                        if (res.status == 'true') {
                            if (res.result.length == 0) {
                                that.nodata = true;
                            } else {
                                that.nodata = false;
                            }
                            that.currentPage = res.result.indexPage;
                            that.totalPage = res.result.pageCount;
                            that.listdata = res.result.rows;
                            that.tansList()
                        } else if (res.status == 'false') {
                            that.alert(res.result);
                        } else {
                            that.alert('系统错误！');
                        }
                    },
                    complete: function () {
                        layer.close(loader);
                        $('#textarea').css('max-height', $(window).height() - $('#textarea').offset().top - 10)
                    }
                });
            },
            getRoomsAndDepart: function() {
                let postData = {type:1, funcType: 11};
                let that = this;
                $.ajax({
                    url: '/produce/ProductionDaily!showProdWx.action',
                    type: "post",
                    data: postData,
                    dataType: "json",
                    success: function(res) {
                        if (res.msg == 'success') {
                            that.storeroom = res.srs;
                            that.departments = res.departs;
                        } else {
                            that.toast('获取库房和部门数据失败！');
                        }
                    }
                });
                // this.$post('/produce/ProductionDaily!showProdWx.action', {type:1, funcType: 11})
                //     .then(response => {
                //         if (response.data.msg == 'success') {
                //             this.storeroom = response.data.srs;
                //             this.departments = response.data.departs;
                //         } else {
                //             this.toast('获取库房和部门数据失败！');
                //         }
                //     });
            },
            getRooms: function() {
                // let postData = {functionTypes: 11};
                // let that = this;
                // $.ajax({
                //     url: '/sales/Salespermission!getPermisForStore.action',
                //     type: "post",
                //     data: postData,
                //     dataType: "json",
                //     success: function(res) {
                //         if (res.msg == 'true') {
                //             that.storeroom = res.storeroom;
                //         } else {
                //             that.toast('获取库房数据失败！');
                //         }
                //     }
                // });
                this.$post('/sales/Salespermission!getPermisForStore.action', qs.stringify({functionTypes: 11}))
                    .then(response => {
                        let data = response.data;
                        if (data.msg == 'true') {
                            this.storeroom = data.storeroom;
                        } else {
                            this.toast('获取库房数据失败！');
                        }
                    })
            },
            getDeparts: function() {
                // let postData = {functionTypes: 11, departype: 1};
                // let that = this;
                // $.ajax({
                //     url: '/sales/Salespermission!getPermisForDepart.action',
                //     type: "post",
                //     data: postData,
                //     dataType: "json",
                //     success: function(res) {
                //         if (res.msg == 'true') {
                //             that.departments = res.department;
                //         } else {
                //             that.toast('获取部门数据失败！');
                //         }
                //     }
                // });
                this.$post('/sales/Salespermission!getPermisForDepart.action', qs.stringify({functionTypes: 11, departype: 1}))
                    .then(response => {
                        let data = response.data;
                        if (data.msg == 'true') {
                            this.departments = data.department;
                        } else {
                            this.toast('获取部门数据失败！');
                        }
                    })
            },
            getCustomer: function() {
                let departid = $('#currentDepart').val();
                this.axios({
                    method: 'get',
                    responseType: 'json',
                    url: '/sales/Customer!getCustomers.action',
                    params: {departid: departid, functiontype: 13}
                }).then(response => {
                    if (response.data.msg == "success") {
                        this.customers = response.data.customers;
                    } else {
                        this.toastText('获取客户数据失败');
                    }
                });
            },
            getApplyer: function(departid = '') {
                this.$post('/sales/Salespermission!getSalers.action', qs.stringify({departmentid: departid, permiss: 2}))
                    .then(response => {
                        let data = response.data;
                        if (data.msg == "true") {
                            this.applyers = data.users;
                        } else {
                            this.toast('获取销售人员数据失败');
                        }
                    });
            },
            getProduct: function() {
                this.$post('/sales/Sellform!findProductinfo.action')
                    .then(response => {
                    let data = response.data;
                    if (data.status == 'true') {
                        this.products = data.result;
                    } else {
                        this.toast('获取产品数据失败');
                    }
                });
            },
            getSpecByPro: function() {

            },
            getSps: function(productid) {
                this.axios({
                    method: 'get',
                    url: '/produce/Whinapply!getSpeByproduct.action',
                    params: {productid: productid}
                }).then((response) => {
                    if (response.data.msg == 'success') {
                        let data = response.data;
                        this.sps = data.specifications;
                    } else {
                        this.toastError("获取规格数据失败");
                    }

                })
            },
            getStatus: function() {
                this.$post('/sales/Sellform!findDict.action?type=17', {type: 17})
                    .then(response => {
                    if (response.statusText == "OK") {
                        let data = response.data;
                        this.stats = data.filter(item => {
                            return item.dictkey != 0;
                        });
                        this.stats.push(data.filter(item => {
                            return item.dictkey == 0;
                        })[0]);
                        //状态多选
                        this.initStatusSelect();
                    } else {
                        this.toast('获取状态数据失败');
                    }
                });
            },
            getPaytypes: function() {
                this.$post('/sales/Sellform!findDict.action?type=45', {type: 45})
                    .then(response => {
                    if (response.statusText == "OK") {
                        this.paytypes = response.data;
                        //支付类型多选
                        this.initPaytypeSelect();
                    } else {
                        this.toast('获取支付类型数据失败');
                    }
                });
            },
            initStatusSelect: function () {
                layui.xmSelect.render({
                    el: '#statline',
                    tips: '请选择状态',
                    name: 'statline',
                    prop: {
                        name: 'dicttext',
                        value: 'dictkey'
                    },
                    data: this.stats
                })
            },
            initPaytypeSelect: function () {
                layui.xmSelect.render({
                    el: '#paytype',
                    tips: '请选择支付类型',
                    name: 'paytype',
                    prop: {
                        name: 'dicttext',
                        value: 'dictkey'
                    },
                    data: this.paytypes
                })
            },
            exportExcel:function (){
                if (this.dateToValue($('#endtime').val()) < this.dateToValue($('#starttime').val())) {
                    this.toastText('结束时间须大于起始时间！');
                    return;
                }
                var that = this;
                let postData  = this.setPostData();
                window.location.href="/sales/Sellform!exportOrderData.action?starttime=" + postData.starttime+ "&endtime=" + postData.endtime+ "&depcondition=" + postData.depcondition+ "&applycondition=" + postData.applycondition+ "&srcondition=" + postData.srcondition+ "&customercondition=" + postData.customercondition+ "&ordercondition=" + postData.ordercondition+ "&depguid=" + postData.depguid+ "&operatorid=" + postData.operatorid+ "&storermguid=" + postData.storermguid+ "&customerguid=" + postData.customerguid+ "&productguid=" + postData.productguid+ "&spguid=" + postData.spguid + "&stat=" + postData.stat + "&paytype=" + postData.paytype + "&startsettletime=" + postData.startsettletime + "&endsettletime=" + postData.endsettletime + "&startouttime=" + postData.startouttime + "&endouttime=" + postData.endouttime + "&pageNo=" + postData.pageNo;
            },
            setPostData: function (type = '') {
                let that = this;

                let postData = {pageNo:this.exportpage};
                if (type != 'search') {
                    postData.pageNo = that.currentPage;
                }
                postData.pageSize = that.pageSize;
                that.starttime = $('#starttime').val();
                that.endtime = $('#endtime').val();
                that.starttime2 = $('#starttime2').val();
                that.endtime2 = $('#endtime2').val();
                that.starttime3 = $('#starttime3').val();
                that.endtime3 = $('#endtime3').val();
                that.srguid =  $('#srguid').val();
                that.depcondition =  $('#depcondition').is(':checked') ? $('#depcondition').val() : '';
                that.applycondition =  $('#applycondition').is(':checked') ? $('#applycondition').val() : '';
                that.srcondition =  $('#srcondition').is(':checked') ? $('#srcondition').val() : '';
                that.customercondition =  $('#customercondition').is(':checked') ? $('#customercondition').val() : '';
                that.ordercondition =  $('#ordercondition').val();

                that.currentDepart = $('#currentDepart').val();
                that.currentApply = $('#currentApply').val();
                that.currentRoom = $('#currentRoom').val();
                that.currentCustomer = $('#currentCustomer').val();
                that.currentProduct = $('#currentProduct').val();
                that.currentSp = $('#currentSp').val();
                that.currentStatus = $('#currentStatus').val();

                postData.starttime = that.starttime;
                postData.endtime = that.endtime;
                postData.startsettletime = that.starttime2;
                postData.endsettletime = that.endtime2;
                postData.startouttime = that.starttime3;
                postData.endouttime = that.endtime3;
                postData.srguid = that.srguid;
                postData.depcondition = that.depcondition;
                postData.applycondition = that.applycondition;
                postData.srcondition = that.srcondition;
                postData.customercondition = that.customercondition;
                postData.ordercondition = that.ordercondition;

                //postData.depguid = that.currentDepart;
                postData.depguid = that.currentDepart;
                postData.operatorid = that.currentApply;
                postData.storermguid = that.currentRoom;
                postData.customerguid = that.currentCustomer;
                postData.productguid = that.currentProduct;
                postData.spguid = that.currentSp;
                postData.stat = that.currentStatus;
                postData.search = $('#sellcode').val();
                postData.stats = $("input[name='statline']").val();
                postData.paytypes = $("input[name='paytype']").val();
                return postData;
            }
        }
    }
</script>
